<script type="text/html" template lay-done="layui.data.sendParams(d.params)">
  <table id="LAY-content-attachment-show" lay-filter="LAY-content-attachment-show"></table>
</script>

<script>
  layui.data.sendParams = function(params) {
    const fromData = params.data;
    layui.use(['admin', 'baseMethods'], function () {
      let {flow,baseMethods} = layui;
      baseMethods.table({
        elem: '#LAY-content-attachment-show',
        url: '/content/attachment/list',
        toolbar: '#LAY-content-attachment-toolbar',
        cols: [[
          {checkbox: true,fixed: true},
          {field: 'file_name', title: '文件名'},
          {field: 'type', title: '展示', width: 120,
            templet: function (d) {
              if (d.type.indexOf("image") !== -1) {
                return `<img lay-src="${AppGeneral.storage(d.path)}" alt="${d.file_name}" width="28" height="28" onerror="AppGeneral.imgError(this)">`
              }
              return `<img src="./admin/img/ico/${d.suffix}.png" width="28" height="28" onerror="AppGeneral.imgError(this)">`;
            }
          },
          {field: 'size', title: '文件大小', width: 130, templet: function (d) { return AppGeneral.fileSize(d.size); }},
          {field: 'storage', title: '储存方式', width: 120},
          {field: 'created_at', title: '添加时间', width: 180},
          {fixed: 'right', width: 150, align:'center', templet: '#LAY-content-attachment-tool'}
        ]],
        done: function () {
          flow.lazyimg();
        }
      });
    })
  };
</script>